import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
// 保研批次管理列表
function getBatchList(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/getBatchList`,
      method: 'post',
      data
  });
}
// 保研批次维护列表
function getList(grade,id) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/getAllFacultyStudent?grade=${grade}&id=${id}`,
      method: 'get'
  });
}
// 查询编辑数据或详情
function getBatchById(id) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/getBatchById?id=${id}`,
      method: 'get'
  });
}
// 新增或编辑批次保存
function saveBatch(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/saveBatch`,
      method: 'post',
      data
  });
}
// 保研批次维护列表删除
function deleteBatch(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/deleteBatchList`,
      method: 'post',
      data
  });
}
// 发布
function release(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/release`,
      method: 'post',
      data
  });
}
// 取消发布
function cancelRelease(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/cancelRelease`,
      method: 'post',
      data
  });
}
// 维护部门（模糊查询）
function getDeptList(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/getDeptList?deptName`,
      method: 'post',
      data
  });
}
// 导出
function exportList(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/exportList`,
      method: 'post',
      data
  });
}
/**
* 获取key
*/
function exportStatus(key) {
  return fetch({
      url: `${baseUrl}/export/result/${key}`,
      method: 'get',
  });
}
// 下载模板
function downloadTemplate() {
  let url = `${baseUrl}/recommendPostBatch/downloadTemplate`;
  window.open(url);
}
// 导入
function batchImport(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/batchImport`,
      method: 'post',
      data
  });
}
const pgdBatchManageApi = {
  getBatchList,
  getList,
  getBatchById,
  saveBatch,
  deleteBatch,
  release,
  getDeptList,
  cancelRelease,
  exportList,
  exportStatus,
  downloadTemplate,
  batchImport
}
export default pgdBatchManageApi;
